package com.admin.service.impl;

import com.admin.entity.Profession;
import com.admin.dao.ProfessionMapper;
import com.admin.service.ProfessionService;
import com.admin.vo.query.ProfessionQueryVo;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 专业表 服务实现类
 * </p>
 *
 * @author szy
 * @since 2023-03-02
 */
@Service
public class ProfessionServiceImpl extends ServiceImpl<ProfessionMapper, Profession> implements ProfessionService {

    @Override
    public IPage<Profession> getProfessionListByPage(IPage<Profession> page, ProfessionQueryVo professionQueryVo) {
        //创建条件构造器对象
        QueryWrapper<Profession> queryWrapper = new QueryWrapper<Profession>();
        //专业名称
        queryWrapper.like(!ObjectUtils.isEmpty(professionQueryVo.getProfessionName()),
                "profession_name",professionQueryVo.getProfessionName());
        //学院
        queryWrapper.eq(!ObjectUtils.isEmpty(professionQueryVo.getAcademyId()),
                "academy_id",professionQueryVo.getAcademyId());
        //查询并返回数据
        return baseMapper.selectPage(page,queryWrapper);
    }
}
